package com.woniuxy.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woniuxy.controller.form.PageAllVoteForm;
import com.woniuxy.controller.info.PageAllVoteInfo;
import com.woniuxy.dao.VoteTopicDao;
import com.woniuxy.service.VoteTopicService;
import com.woniuxy.util.Result;
import com.woniuxy.util.WoniuxyBeanCopyUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {
    @Resource
    private RedisTemplate<String,Object> ort;

    @Resource
    private VoteTopicService voteTopicService;

    @Resource
    private VoteTopicDao voteTopicDao;

    @RequestMapping("/test")
    public Result test(PageAllVoteForm pageAllVoteForm) throws JsonProcessingException {
        System.out.println(111);
        ObjectMapper mapper = new ObjectMapper();
        PageAllVoteForm page = voteTopicService.page(pageAllVoteForm,null);
        PageAllVoteInfo pageAllVoteInfo = WoniuxyBeanCopyUtil.copyOne(pageAllVoteForm, PageAllVoteInfo.class);
        System.out.println(page.toString());
        System.out.println(pageAllVoteInfo.toString());
        return Result.success(200,"1",pageAllVoteInfo.toString());
    }
}
